package cn.ickck.law_paper_final.mapper;

import cn.ickck.law_paper_final.model.entity.CreditCard;
import cn.ickck.law_paper_final.provider.CreditCardProvider;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.UpdateProvider;

import java.util.List;

/**
 * @Author: ck
 * @Description:
 * @Date: Create in 16:26 2020/10/17
 */
public interface CreditCardMapper {
    @Select("select * from credit_card")
    List<CreditCard> findAll();

    @Delete("delete from credit_card where id = #{id}")
    void deleteById(Integer id);

    void insert(CreditCard creditCard);

     @Select("select count(*) from credit_card")
    int count();


    @UpdateProvider(type = CreditCardProvider.class,method = "updateCreditCard")
    void update(CreditCard creditCard);


    @Select("select * from credit_card limit #{start},#{end}")
    List<CreditCard> selectByPage(int start, int end);


    @Select("select * from credit_card where party like  CONCAT('%',#{key},'%') or `key` = #{key}")
    List<CreditCard> findByNameOrKey(String key);

    @Delete("delete from credit_card where `key` = #{key}")
    void deleteByKey(String key);
}
